﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZkSurvey.Web.Helper;

namespace ZkSurvey.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
#if DEBUG
            this.UserName.Text = "admin";
            this.PassWord.Text = "admin";
            this.PassWord.TextMode = TextBoxMode.SingleLine;
#endif
        }
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            if (UserHelper.Login(this.UserName.Text, this.PassWord.Text))
            {
                if (HttpContext.Current.Session["lastUrl"] != null)
                {
                    string url = HttpContext.Current.Session["lastUrl"].ToString();
                    HttpContext.Current.Session["lastUrl"] = null;
                    Response.Redirect(url, true);
                }
                else
                    Response.Redirect("Default.aspx", true);
            }
            else
            {
                this.LtrMsg.Text = "用户名或密码错误！";
            }
        }
    }
}